<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>立体建筑物GeoJson图层 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,web-icons,bootstrap,layer,toastr,nprogress,haoutil,echarts,turf,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
    <link rel="stylesheet" href="./css/e20_geojson_buildings.css" />
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 右侧图表面板-->
    <div class="achart_container">
      <div class="right_item">
        <div class="_item_top">
          <div class="_item_title">接入建筑栋数</div>
        </div>
        <div class="_item_row _item_full_box_width justify-between">
          <div class="row1 flex-1">
            <img src="./img/icon/监测建筑.png" alt="" class="icon" />
            <div class="row1_right">
              <div class="right_title">87</div>
              <div class="right_sub_title">监测建筑</div>
            </div>
          </div>
          <div class="row1 flex-1 ml">
            <img src="./img/icon/监测面积.png" alt="" class="icon" />
            <div class="row1_right">
              <div class="right_title">2021</div>
              <div class="right_sub_title">监测面积(万m²)</div>
            </div>
          </div>
        </div>
        <div class="_item_row" style="align-items: flex-start">
          <div class="row3">
            <div class="_item_row_box3">
              <div class="ring1">
                <div id="ring"></div>
              </div>
            </div>
          </div>
          <div class="row2 flex items-center">
            <div class="_item_row_box2">
              <div class="box2_item" count="64">办公建筑</div>
              <div class="box2_item1" count="1">综合建筑</div>
              <div class="box2_item2" count="4">商场建筑</div>
              <div class="box2_item3" count="10">宾馆饭店</div>
              <div class="box2_item4" count="1">医疗卫生</div>
              <div class="box2_item5" count="1">文化教育</div>
            </div>
          </div>
        </div>
      </div>
      <div class="right_item bg">
        <div class="right_item">
          <div class="_item_top">
            <div class="_item_title">各类建筑接入情况</div>
          </div>
          <div class="_item_full_box">
            <div class="bar">
              <div id="bar"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="right_item bg">
        <div class="right_item">
          <div class="_item_top">
            <div class="_item_title">能耗趋势</div>
          </div>
          <div class="_item_full_box">
            <div class="bar">
              <div id="line" class="bar_chart"></div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script src="./js/common.js"></script>
    <script src="./js/e20_geojson_buildings.js"></script>
    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      var map;

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            center: { lat: 31.747855, lng: 117.250137, alt: 4401, heading: 360, pitch: -31 },
          },
          terrain: { show: false },
        });

        //创建三维地球场景
        map = new mars3d.Map("mars3dContainer", mapOptions);

        map.basemap = 2017; //蓝色底图

        initEcharts();

        window.toastr.info("文件数据较大，正在加载数据，请稍等片刻……");
        haoutil.loading.show();

        var colorHash = {
          10: "#FFEDA0",
          15: "#FED976",
          20: "#FEB24C",
          25: "#FD8D3C",
          30: "#FC4E2A",
          35: "#E31A1C",
          40: "#BD0026",
          450000: "#800026",
        };

        var geoJsonLayer = new mars3d.layer.GeoJsonLayer({
          name: "建筑物面",
          url: "//data.mars3d.cn/file/geojson/buildings-hf.json",
          symbol: {
            type: "polygonCombine", //大数据面类型，效率高
            styleOptions: {
              color: "#0d3685",
              opacity: 1.0,
              outline: false,
            },
            callback: function (attr, styleOpt) {
              var floor = Number(attr.floor || 1);
              var diffHeight = floor * 5;
              for (var key in colorHash) {
                if (floor <= parseInt(key)) {
                  return { height: 0, diffHeight: diffHeight, color: colorHash[key] };
                }
              }
              return { height: 0, diffHeight: diffHeight };
            },
          },
          popup: "all",
        });
        map.addLayer(geoJsonLayer);

        //绑定事件
        geoJsonLayer.on(mars3d.EventType.load, function (event) {
          console.log("数据加载完成", event);

          haoutil.loading.hide(); //关闭
        });

        //在layer上绑定监听事件
        geoJsonLayer.on(mars3d.EventType.click, function (event) {
          let pickedItem = event.graphic.attr;
          console.log("单击了合并对象中的单个值为", pickedItem);
        });
      }
    </script>
  </body>
</html>
